package com.study.bean;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.annotation.PostConstruct;
import java.io.Serializable;
import java.util.Date;

/**
 * @author study
 * @version 1.0
 * @description
 * @date 2020/6/6 20:35
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY) // 设置不为空的时候返回
@ApiModel(value = "Person对象", description = "测试 Swagger实体类")
public class Person implements Serializable {

    @ApiModelProperty(value = "年龄")
    private Integer age;
    // 存储子节点的集合，初始化是为了避免空指针异常|使用java8stream设置无需给定初始值
    @JsonInclude(JsonInclude.Include.NON_EMPTY) // 设置不为空的时候返回
    @JSONField(serialzeFeatures = {SerializerFeature.WriteNullListAsEmpty, SerializerFeature.UseSingleQuotes})
    //设置使用单引号|这个是fastjson的配置
    @ApiModelProperty(value = "用户名")
    private String name;
    @ApiModelProperty(value = "生日")
    private Date birthday;

    static {
        /* 静态代码块只在 类加载的时候执行一次 */
        System.out.println("静态代码块");
    }

    {
        /* 每创建一个对象都会执行 */
        System.out.println("普通代码块");
    }
}
